<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- customwidget.qdoc -->
  <title>QDesignerCustomWidgetInterface 类 | Qt设计师手册</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtdesigner-manual.html">Qt设计师手册</a></td><td ><a href="qtdesigner-module.html">C++ 类</a></td><td >QDesignerCustomWidgetInterface</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtdesigner-manual.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#public-functions">公用函数</a></li>
<li class="level1"><a href="#macros">宏</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QDesignerCustomWidgetInterface 类</h1>
<!-- $$$QDesignerCustomWidgetInterface-brief -->
<p><a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a> 
<span lang="zh-cn">类允许</span>Qt 设计师 <span lang="zh-cn">访问和构建自定义组件。</span><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qdesignercustomwidgetinterface.html#details"><font style="vertical-align: inherit;">更多...</font></a></p>
<!-- @@@QDesignerCustomWidgetInterface -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign">头文件：</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QDesignerCustomWidgetInterface&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += designer</td></tr></table></div><ul>
<li><a href="qdesignercustomwidgetinterface-members.html">所有成员的列表，包括继承成员。</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">公用函数</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#dtor.QDesignerCustomWidgetInterface">~QDesignerCustomWidgetInterface</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#codeTemplate">codeTemplate</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QWidget *</td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#createWidget">createWidget</a></b>(QWidget *<i>parent</i>) = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#domXml">domXml</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#group">group</a></b>() const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QIcon </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#icon">icon</a></b>() const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#includeFile">includeFile</a></b>() const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#initialize">initialize</a></b>(QDesignerFormEditorInterface *<i>formEditor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#isContainer">isContainer</a></b>() const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#isInitialized">isInitialized</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#name">name</a></b>() const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#toolTip">toolTip</a></b>() const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#whatsThis">whatsThis</a></b>() const = 0</td></tr>
</table></div>
<a name="macros"></a>
<h2 id="macros"><font style="vertical-align: inherit;">宏</font></h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdesignercustomwidgetinterface.html#QDESIGNER_WIDGET_EXPORT">QDESIGNER_WIDGET_EXPORT</a></b></td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QDesignerCustomWidgetInterface-description -->
<div class="descr">
<h2 id="details">详细信息</h2>
<p><a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a> 
<span lang="zh-cn">类允许</span>Qt 设计师 <span lang="zh-cn">访问和构建自定义组件。</span></p>
<p><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qdesignercustomwidgetinterface.html"><font style="vertical-align: inherit;">QDesignerCustomWidgetInterface</font></a><font style="vertical-align: inherit;">提供了一个带有界面的自定义组件。该类包含一组函数，必须对其进行子类化以返回有关组件的基本信息，例如其类名和其头文件的名称。必须实现其他功能以在加载插件时初始化插件，并构造自定义组件的实例供</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">使用。</font></p>
<p><font style="vertical-align: inherit;">在实现自定义组件时，您必须</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qdesignercustomwidgetinterface.html"><font style="vertical-align: inherit;">继承 QDesignerCustomWidgetInterface</font></a><font style="vertical-align: inherit;">以将您的组件公开给</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">。例如，这是</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qtdesigner-customwidgetplugin-example.html"><font style="vertical-align: inherit;"><span lang="zh-cn">自定义组件插件</span>示例</font></a><font style="vertical-align: inherit;">中使用的插件的声明，它允许</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">使用模拟时钟自定义组件：</font></p>
<pre class="cpp">

  <span class="keyword">class</span> AnalogClockPlugin : <span class="keyword">public</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">,</span> <span class="keyword">public</span> <span class="type"><a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a></span>
  {
      Q_OBJECT
      Q_PLUGIN_METADATA(IID <span class="string">&quot;org.qt-project.Qt.QDesignerCustomWidgetInterface&quot;</span>)
      Q_INTERFACES(<span class="type"><a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a></span>)
  <span class="keyword">public</span>:
      <span class="keyword">explicit</span> AnalogClockPlugin(<span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>parent <span class="operator">=</span> nullptr);

      bool isContainer() <span class="keyword">const</span> override;
      bool isInitialized() <span class="keyword">const</span> override;
      <span class="type">QIcon</span> icon() <span class="keyword">const</span> override;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> domXml() <span class="keyword">const</span> override;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> group() <span class="keyword">const</span> override;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> includeFile() <span class="keyword">const</span> override;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> name() <span class="keyword">const</span> override;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> toolTip() <span class="keyword">const</span> override;
      <span class="type"><a href="../qtcore/qstring.html">QString</a></span> whatsThis() <span class="keyword">const</span> override;
      <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> <span class="operator">*</span>createWidget(<span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> <span class="operator">*</span>parent) override;
      <span class="type">void</span> initialize(<span class="type"><a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a></span> <span class="operator">*</span>core) override;

  <span class="keyword">private</span>:
      bool initialized <span class="operator">=</span> <span class="keyword">false</span>;
  };

</pre>
<p>注意，类定义中唯一特定于这个特定自定义组件的部分是类名。此外，由于我们正在实现一个接口，我们必须确保使用<a href="../qtcore/qobject.html#Q_INTERFACES">Q_INTERFACES</a>()宏让元对象系统知道它。这使<font style="vertical-align: inherit;">得</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i>能够使用<a href="../qtcore/qobject.html#qobject_cast">qobject_cast</a>()函数来转换<a href="../qtcore/qobject.html">QObject</a>指针来查询所支持的接口。</p>
<p>在Qt 设计师加载自定义组件插件后，它调用接口的initialize()函数来设置它可能需要的任何资源。使用<a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a>参数调用该函数，该参数为插件提供了通往所有<i>Qt 设计师</i> 
API的网关。</p>
<p><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">通过使用合适的父组件调用插件的</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qdesignercustomwidgetinterface.html#createWidget"><font style="vertical-align: inherit;">createWidget</font></a><font style="vertical-align: inherit;"> () 函数来构造自定义组件的实例。插件必须构造并返回具有指定父组件的自定义组件的实例。</font></p>
<p>使用<a href="../qtcore/qtplugin.html#Q_PLUGIN_METADATA">Q_PLUGIN_METADATA</a>()宏导出自定义组件插件到<i>Qt 设计师</i> 
。例如，如果一个名为<code>libcustomwidgetplugin.so</code> (在Unix上)或<code>libcustomwidget.dll</code>(在Windows上)的库包含一个名为<code>MyCustomWidget</code>的组件类，我们可以通过在包含插件头的文件中添加以下行来导出它:</p>
<pre class="cpp">

  Q_PLUGIN_METADATA(IID <span class="string">&quot;org.qt-project.Qt.QDesignerCustomWidgetInterface&quot;</span>)

</pre>
<p><font style="vertical-align: inherit;">这个宏确保</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">可以访问和构建自定义组件。没有这个宏，</font><i><font style="vertical-align: inherit;">Qt 设计师 </font></i>
<font style="vertical-align: inherit;"><span lang="zh-cn">就无</span>法使用它。</font></p>
<p><font style="vertical-align: inherit;">实现自定义组件插件时，您将其构建为单独的库。如果要在同一个库中包含多个自定义组件插件，则必须另外子类</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qdesignercustomwidgetcollectioninterface.html"><font style="vertical-align: inherit;">QDesignerCustomWidgetCollectionInterface</font></a><font style="vertical-align: inherit;">。</font></p>
<p><b><font style="vertical-align: inherit;">警告：</font></b><font style="vertical-align: inherit;">如果您的自定义组件插件包含</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtcore/qvariant.html"><font style="vertical-align: inherit;">QVariant</font></a><font style="vertical-align: inherit;">属性，请注意仅支持以下</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtcore/qvariant-obsolete.html#Type-enum"><font style="vertical-align: inherit;">类型</font></a><font style="vertical-align: inherit;">：</font></p>
<ul>
<li>QVariant::ByteArray</li>
<li>QVariant::Bool</li>
<li>QVariant::Color</li>
<li>QVariant::Cursor</li>
<li>QVariant::Date</li>
<li>QVariant::DateTime</li>
<li>QVariant::Double</li>
<li>QVariant::Int</li>
<li>QVariant::Point</li>
<li>QVariant::Rect</li>
<li>QVariant::Size</li>
<li>QVariant::SizePolicy</li>
<li>QVariant::String</li>
<li>QVariant::Time</li>
<li>QVariant::UInt</li>
</ul>
<p><font style="vertical-align: inherit;">有关使用</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qdesignercustomwidgetinterface.html"><font style="vertical-align: inherit;">QDesignerCustomWidgetInterface</font></a><font style="vertical-align: inherit;">类的完整示例，请参阅</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qtdesigner-customwidgetplugin-example.html"><font style="vertical-align: inherit;">自定义组件示例</font></a><font style="vertical-align: inherit;">。该示例展示了如何为</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">创建自定义组件插件。</font></p>
</div>
<p><b><font style="vertical-align: inherit;">请</font></b><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qdesignercustomwidgetcollectioninterface.html"><font style="vertical-align: inherit;">参阅 QDesignerCustomWidgetCollectionInterface</font></a><font style="vertical-align: inherit;">和</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/designer-creating-custom-widgets.html"><font style="vertical-align: inherit;">为 Qt 设计师 创建自定义组件</font></a><font style="vertical-align: inherit;">。</font></p>
<!-- @@@QDesignerCustomWidgetInterface -->
<div class="func">
<h2>成员函数文档</h2>
<!-- $$$~QDesignerCustomWidgetInterface[overload1]$$$~QDesignerCustomWidgetInterface -->
<h3 class="fn" id="dtor.QDesignerCustomWidgetInterface"><a name="dtor.QDesignerCustomWidgetInterface"></a><code>[virtual] </code>QDesignerCustomWidgetInterface::<span class="name">~QDesignerCustomWidgetInterface</span>()</h3>
<p><font style="vertical-align: inherit;">销毁自定义组件界面。</font></p>
<!-- @@@~QDesignerCustomWidgetInterface -->
<!-- $$$codeTemplate[overload1]$$$codeTemplate -->
<h3 class="fn" id="codeTemplate"><a name="codeTemplate"></a><code>[virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QDesignerCustomWidgetInterface::<span class="name">codeTemplate</span>() const</h3>
<p><font style="vertical-align: inherit;">此函数保留供</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">将来使用。</font></p>
<!-- @@@codeTemplate -->
<!-- $$$createWidget[overload1]$$$createWidgetQWidget* -->
<h3 class="fn" id="createWidget"><a name="createWidget"></a><code>[pure virtual] </code><span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> *QDesignerCustomWidgetInterface::<span class="name">createWidget</span>(<span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> *<i>parent</i>)</h3>
<p>使用给定的<i>parent<span lang="zh-cn">（</span></i>父组件<span lang="zh-cn">）</span>返回自定义组件的新实例。</p>
<!-- @@@createWidget -->
<!-- $$$domXml[overload1]$$$domXml -->
<h3 class="fn" id="domXml"><a name="domXml"></a><code>[virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QDesignerCustomWidgetInterface::<span class="name">domXml</span>() const</h3>
<p><font style="vertical-align: inherit;">将用于描述自定义组件属性的 XML 返回给</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">。</font></p>
<!-- @@@domXml -->
<!-- $$$group[overload1]$$$group -->
<h3 class="fn" id="group"><a name="group"></a><code>[pure virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QDesignerCustomWidgetInterface::<span class="name">group</span>() const</h3>
<p><font style="vertical-align: inherit;">返回自定义组件所属的组的名称。</font></p>
<!-- @@@group -->
<!-- $$$icon[overload1]$$$icon -->
<h3 class="fn" id="icon"><a name="icon"></a><code>[pure virtual] </code><span class="type">QIcon</span> QDesignerCustomWidgetInterface::<span class="name">icon</span>() const</h3>
<p><font style="vertical-align: inherit;">返回用于在</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">的组件框中表示自定义组件的图标。</font></p>
<!-- @@@icon -->
<!-- $$$includeFile[overload1]$$$includeFile -->
<h3 class="fn" id="includeFile"><a name="includeFile"></a><code>[pure virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QDesignerCustomWidgetInterface::<span class="name">includeFile</span>() const</h3>
<p><font style="vertical-align: inherit;">返回</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdoc/uic.html"><font style="vertical-align: inherit;">uic</font></a><font style="vertical-align: inherit;">在为自定义组件创建代码时使用的包含文件的路径。</font></p>
<!-- @@@includeFile -->
<!-- $$$initialize[overload1]$$$initializeQDesignerFormEditorInterface* -->
<h3 class="fn" id="initialize"><a name="initialize"></a><code>[virtual] </code><span class="type">void</span> QDesignerCustomWidgetInterface::<span class="name">initialize</span>(<span class="type"><a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a></span> *<i>formEditor</i>)</h3>
<p>初始化组件以使用指定的<i>formEditor</i> 接口。</p>
<p><b>请参考 </b><a href="qdesignercustomwidgetinterface.html#isInitialized">isInitialized</a>()<span lang="zh-cn">。</span></p>
<!-- @@@initialize -->
<!-- $$$isContainer[overload1]$$$isContainer -->
<h3 class="fn" id="isContainer"><a name="isContainer"></a><code>[pure virtual] </code><span class="type">bool</span> QDesignerCustomWidgetInterface::<span class="name">isContainer</span>() const</h3>
<p><font style="vertical-align: inherit;">如果打算将自定义组件用作容器，则返回 true；否则返回false。</font></p>
<p><font style="vertical-align: inherit;">大多数自定义组件不用于保存其他组件，因此它们的此函数实现将返回 false，但自定义容器将返回 true 以确保它们在</font><i><font style="vertical-align: inherit;">Qt 设计师 </font></i>
<font style="vertical-align: inherit;"><span lang="zh-cn">中正</span>确运行。</font></p>
<!-- @@@isContainer -->
<!-- $$$isInitialized[overload1]$$$isInitialized -->
<h3 class="fn" id="isInitialized"><a name="isInitialized"></a><code>[virtual] </code><span class="type">bool</span> QDesignerCustomWidgetInterface::<span class="name">isInitialized</span>() const</h3>
<p><font style="vertical-align: inherit;">如果组件已初始化，则返回 true；否则返回false。</font></p>
<p><b>请参考 </b><a href="qdesignercustomwidgetinterface.html#initialize">initialize</a>()<span lang="zh-cn">。</span></p>
<!-- @@@isInitialized -->
<!-- $$$name[overload1]$$$name -->
<h3 class="fn" id="name"><a name="name"></a><code>[pure virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QDesignerCustomWidgetInterface::<span class="name">name</span>() const</h3>
<p><font style="vertical-align: inherit;">返回接口提供的自定义组件的类名。</font></p>
<p><font style="vertical-align: inherit;">返回的名称</font><i><font style="vertical-align: inherit;">必须</font></i><font style="vertical-align: inherit;">与用于自定义组件的类名称相同。</font></p>
<!-- @@@name -->
<!-- $$$toolTip[overload1]$$$toolTip -->
<h3 class="fn" id="toolTip"><a name="toolTip"></a><code>[pure virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QDesignerCustomWidgetInterface::<span class="name">toolTip</span>() const</h3>
<p><font style="vertical-align: inherit;">在工具提示中返回</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">可以使用的组件的简短描述。</font></p>
<!-- @@@toolTip -->
<!-- $$$whatsThis[overload1]$$$whatsThis -->
<h3 class="fn" id="whatsThis"><a name="whatsThis"></a><code>[pure virtual] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QDesignerCustomWidgetInterface::<span class="name">whatsThis</span>() const</h3>
<p style="width: 70%">在组件的“What's This?”帮助中返回可由<i>Qt 设计师</i> 使用的组件的描述。</p>
<!-- @@@whatsThis -->
</div>
<div class="macros">
<h2><font style="vertical-align: inherit;">宏文档</font></h2>
<!-- $$$QDESIGNER_WIDGET_EXPORT[overload1]$$$QDESIGNER_WIDGET_EXPORT -->
<h3 class="fn" id="QDESIGNER_WIDGET_EXPORT"><a name="QDESIGNER_WIDGET_EXPORT"></a><span class="name">QDESIGNER_WIDGET_EXPORT</span></h3>
<p>这个宏用于定义自定义组件，以确保它们正确地从插件导出，用于<i>Qt 设计师</i>。</p>
<p><font style="vertical-align: inherit;">在某些平台上，</font><i><font style="vertical-align: inherit;">Qt 设计师</font></i><font style="vertical-align: inherit;">创建新组件所需的符号会被构建系统从插件中删除，使它们无法使用。使用此宏可确保符号保留在这些平台上，并且对其他平台没有副作用。</font></p>
<p><font style="vertical-align: inherit;">例如，</font><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/qtdesigner-worldtimeclockplugin-example.html"><font style="vertical-align: inherit;">世界时间时钟插件</font></a><font style="vertical-align: inherit;">示例使用以下声明导出自定义组件类：</font></p>
<pre class="cpp">

  <span class="keyword">class</span> QDESIGNER_WIDGET_EXPORT WorldTimeClock : <span class="keyword">public</span> <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span>
  {
      Q_OBJECT
      ...
  };

</pre>
<p><font style="vertical-align: inherit;">这个函数是在 Qt 4.1 中引入的。</font></p>
<p><b><font style="vertical-align: inherit;">请参阅</font></b><a href="file:///E:/WLL/work/Qt5.12-Document-Trans-in-Chinese/qtdesigner/designer-creating-custom-widgets.html"><font style="vertical-align: inherit;">为 Qt 设计师创建自定义组件</font></a><font style="vertical-align: inherit;">。</font></p>
<!-- @@@QDESIGNER_WIDGET_EXPORT -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
